package com.goodfather.textbook.youdao.pad.bean;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import java.util.List;

public class Pages implements Parcelable, Comparable {
    public String bookId;

    public String publishingId;

    public String pageId;

    public int pageNo;

    public String lessonId;

    public String displayEn;

    public String displayCn;

    public String beginTime;

    public String endTime;

    public boolean isFree;

    public String imageUrl;

    /**
     * page默认没有音频url,需要到所属的lesson中去找
     */
    public String audioUrl;


    public List<Sentence> sentences;

    public List<Sentence> preSentence;

    public int pageNum;

    /**
     * 当前页所属下标
     */
    public int index;

    protected Pages(Parcel in) {
        bookId = in.readString();
        publishingId = in.readString();
        pageId = in.readString();
        pageNo = in.readInt();
        lessonId = in.readString();
        displayEn = in.readString();
        displayCn = in.readString();
        beginTime = in.readString();
        endTime = in.readString();
        isFree = in.readByte() != 0;
        imageUrl = in.readString();
        audioUrl = in.readString();
        sentences = in.createTypedArrayList(Sentence.CREATOR);
        preSentence = in.createTypedArrayList(Sentence.CREATOR);
        index = in.readInt();
        pageNum = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(bookId);
        dest.writeString(publishingId);
        dest.writeString(pageId);
        dest.writeInt(pageNo);
        dest.writeString(lessonId);
        dest.writeString(displayEn);
        dest.writeString(displayCn);
        dest.writeString(beginTime);
        dest.writeString(endTime);
        dest.writeByte((byte) (isFree ? 1 : 0));
        dest.writeString(imageUrl);
        dest.writeString(audioUrl);
        dest.writeTypedList(sentences);
        dest.writeTypedList(preSentence);
        dest.writeInt(index);
        dest.writeInt(pageNum);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<Pages> CREATOR = new Creator<Pages>() {
        @Override
        public Pages createFromParcel(Parcel in) {
            return new Pages(in);
        }

        @Override
        public Pages[] newArray(int size) {
            return new Pages[size];
        }
    };

    @Override
    public int compareTo(@NonNull Object o) {
        return 0;
    }
}
